package ambika;

import java.util.Scanner;

public class ArithmeticOperations {
	

 /*1.) 11 Times trick*/
	public static void elevenTimes(String number){
	
	 String digitOne = number.substring(0, number.length()-1);
	 String digitTwo = number.substring(1, number.length());
	 int dOne = Integer.parseInt(digitOne);
	 int dTwo = Integer.parseInt(digitTwo);
	  int sum = dOne + dTwo;
	  String s = String.valueOf(sum);
	  if (s.length() == 2){
		  System.out.println((dOne+1)+s.substring(1,s.length()) +digitTwo);
	  }
	  else{
		  System.out.print(digitOne+sum+digitTwo);
	  }
	}
	
	/*2.) Quick Square*/
	public static void quickSquare(String num){
		if( !num.substring(1,num.length()).equals("5") ){
			System.out.println("Please enter a two digit number that ends with a 5.");
			Scanner sn = new Scanner(System.in);
			num = sn.next();
			quickSquare(num);
		}
		else{
			
			int sum = Integer.parseInt(num.substring(0,num.length()-1))  + 1;
			int multiply = Integer.parseInt(num.substring(0, num.length()-1)) * sum;
			String m = String.valueOf(multiply);
			System.out.println(m+25);
			
		}
		
	}
	/*3.) Multiply by 5*/
	public static void multiplyBy5(String number){
		int num = Integer.parseInt(number);
		int div = num/2;
		
		if(div%2 == 0){
			System.out.println(String.valueOf(div) + "0");
		}
		else{
			
			System.out.print(div);
			String d = String.valueOf(div);
			System.out.println(d +"5");
		}
	}
	
	/*4.) Multiply by 9*/
	public static void multiplyBy9(int number){
	
		int firstdigit = (number - 1) ;
		String f = String.valueOf(firstdigit);
		int seconddigit = (10-number);
		String s = String.valueOf(seconddigit);
		System.out.println(f+s);
		
		
	}
	/*5.) Multiply by 4*/
	public static void multiplyBy4(int number){
		number = (number *2) + (number *2);
		System.out.println(number);
	}
	
	/*6.) Calculate a Tip*/
	public static void calculatingTips(double number1, double number2){
		double total = (number1/number2) + ((number1/number2)/2);
		
		System.out.println(total);
	}
	
	/*7 Tough multiplication trick*/
	public static void toughMult(int number1, int number2){
		if((number1%2 == 0)){
			int total = ((number1/2) * (number2*2));
			System.out.println(total);
		}else if((number2%2 == 0)){
			int total = ((number1*2) * (number2/2));
			System.out.println(total);
		}else{
			System.out.println("Make sure one of the numbers is even. Type in the first one again.");
			Scanner sn = new Scanner(System.in);
			int num1 = sn.nextInt();
			System.out.println("Type in the second one again.");
			int num2 = sn.nextInt();
			toughMult(num1, num2);
			
		}
	}
	/*8.) divide by 5*/
	public static void divideBy5(int number){
		int totalDivideFive = number *2;
		String t = String.valueOf(totalDivideFive);
		String lastdigit = t.substring(t.length()-1, t.length());
		t = t.replace(lastdigit, ".");
		System.out.println(t+lastdigit);
		
	}
	/*9.) subtract from 1000*/
	/*10*/
	public static void main (String[] args){
		Scanner sn = new Scanner(System.in);
		System.out.println("Type in a double digit number to multiply by 11.");
		String num1 = sn.next();
		elevenTimes(num1);
		System.out.println();
		System.out.println("Type in another double digit number to square it.");
		String num2= sn.next();
		quickSquare(num2);
		System.out.println();
		System.out.println("Type a number to multiply by 5.");
		String num3= sn.next();
		multiplyBy5(num3);
		System.out.println();
		System.out.println("Type in a number between 1 and 9 to multiply by 9.");
		int num4= sn.nextInt();
		multiplyBy9(num4);
		System.out.println();
		System.out.println("Type in a number to multiply by 4.");
		int num5= sn.nextInt();
		multiplyBy4(num5);
		System.out.println();
		System.out.println("How to calculate a tip? Please type in a number.");
		double num6= sn.nextDouble();
		
		System.out.println("Also type in the tip.");
		double num7= sn.nextDouble();
		calculatingTips(num6, num7);
		System.out.println();
		System.out.println("Type in the first number.");
		int num8= sn.nextInt();
		System.out.println("Type in the second number. What do these multiply to?");
		int num9 = sn.nextInt();
		toughMult(num8,num9);
		System.out.println();
		System.out.println("Type in a number to divide by 5.");
		int num10 = sn.nextInt();
		divideBy5(num10);
	
	}  
	 
	
}
